﻿<UserControl x:Class="ModernAudioTagger.Pages.TagDbResult"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:content="clr-namespace:ModernAudioTagger.Content"
             xmlns:converter="clr-namespace:ModernAudioTagger.Converter"
             xmlns:provider="clr-namespace:ModernAudioTagger.Provider"
             xmlns:view="clr-namespace:ModernAudioTagger.View"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                   
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800">

    <UserControl.DataContext>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="TrackTagVM" />
    </UserControl.DataContext>

    <UserControl.Resources>
        <converter:SelectedCounterConverter x:Key="selectedCounterConverter" />
        <Storyboard x:Key="stb_error">
            <ObjectAnimationUsingKeyFrames 
                Storyboard.TargetName="canvas_alert"
                Storyboard.TargetProperty="Visibility"                
                >
                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{x:Static Visibility.Hidden}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <DockPanel>
        <Grid DockPanel.Dock="Bottom">

            <!-- content root for additional spacing -->
            <Grid Grid.ColumnSpan="2">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="3" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>

                    <StackPanel Orientation="Horizontal" >
                        <mui:ModernButton ToolTip="Change working folder" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource openFolderPathData}" Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.OpenFolderDialogCommand}"  />
                        <mui:ModernButton ToolTip="Refresh folder content" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource refreshPathData}" Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.RefreshFilelistCommand}" Margin="{StaticResource DefaultLeftMargin}"  />
                        <Line Y1="0" Y2="24" Stroke="{DynamicResource SeparatorBackground}" Margin="{StaticResource LineMenuSeparator}"></Line>
                        <mui:ModernButton ToolTip="Tag by selection" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource arrowLeftRightPathData}" Command="{Binding PreviewTagBySelectionCommand}" />
                        <mui:ModernButton ToolTip="Tag by matching name" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource alphabeticalDescPathData}" Margin="{StaticResource DefaultLeftMargin}" Command="{Binding PreviewTagByMatchingNameCommand}" />
                        <mui:ModernButton ToolTip="Tag by matching number" EllipseDiameter="24" IconWidth="16" IconHeight="16" IconData="{StaticResource numericDescPathData}" Margin="{StaticResource DefaultLeftMargin}" Command="{Binding PreviewTagByMatchingNumberCommand}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right">
                        <mui:ModernButton 
                            ToolTip="Help online"
                            Command="{x:Static view:ViewCommands.OpenUrl}" 
                            CommandParameter="{StaticResource doc_autotag}"
                            EllipseDiameter="24" IconWidth="16" IconHeight="16"                           
                            HorizontalAlignment="Right"
                            Margin="{StaticResource DefaultRightMargin}"
                            IconData="{StaticResource helpPathData}"
                        />
                    </StackPanel>

                    <TextBlock FontSize="{StaticResource SmallFontSize}" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="{StaticResource DefaultLeftMargin}">
                            <Run>Items: </Run>
                            <Run>
                                <Binding Mode="OneWay" Source="{x:Static provider:ViewModelLocator.Instance}" Path="MusicDbVM.ListDbResult.Count" />
                            </Run>
                    </TextBlock>

                    <!--<TextBlock FontSize="{StaticResource SmallFontSize}" Grid.Row="2" Grid.Column="3" Margin="0, 0, 120, 0" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                        <Run>Checked: </Run>
                        <Run>
                            <Binding Mode="OneWay" Source="{x:Static provider:ViewModelLocator.Instance}" Path="LocalSystemVM.Files" Converter="{StaticResource selectedCounterConverter}" />
                        </Run>
                    </TextBlock>-->

                    <TextBlock FontSize="{StaticResource SmallFontSize}" Grid.Row="2" Grid.Column="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="{StaticResource DefaultRightMargin}">
                        <Run>Items: </Run>
                        <Run>
                            <Binding Mode="OneWay" Source="{x:Static provider:ViewModelLocator.Instance}" Path="LocalSystemVM.Files.Count" />
                        </Run>
                    </TextBlock>

                    <content:ContentAudioTagHorizontalTop Grid.Row="1" Grid.ColumnSpan="3" />

                    <!--<Border 
                        BorderThickness="0"
                        BorderBrush="{DynamicResource SeparatorBackground}"
                        Grid.ColumnSpan="3" 
                        Grid.Row="2" 
                        Height="Auto" 
                        HorizontalAlignment="Center" 
                        Margin="{StaticResource DefaultMargin}">

                        <StackPanel Orientation="Horizontal" Margin="{StaticResource DefaultMargin}">-->
                            <!--
                            <Button Width="50" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30">
                                <Button.Content>
                                    <Canvas>
                                        <Path Fill="#FF000000" 
                                              Height="20"                                               
                                              Stretch="Uniform"
                                              Canvas.Left="-10" Canvas.Top="-10"
                                              Data="{StaticResource alphabeticalDescPathData}"></Path>
                                    </Canvas>
                                </Button.Content>
                            </Button>
                            -->

                            <!--<mui:ModernButton EllipseDiameter="32" IconWidth="20" IconHeight="20" IconData="{StaticResource alphabeticalDescPathData}" Command="{Binding PreviewTagByMatchingNameCommand}" />
                            <mui:ModernButton EllipseDiameter="32" IconWidth="20" IconHeight="20" IconData="{StaticResource arrowLeftRightPathData}" Margin="16, 0, 0, 0" Command="{Binding PreviewTagBySelectionCommand}" />
                            <mui:ModernButton EllipseDiameter="32" IconWidth="20" IconHeight="20" IconData="{StaticResource numericDescPathData}" Margin="16, 0, 0, 0" Command="{Binding PreviewTagByMatchingNumberCommand}" />-->

                            <!--
                        <Button VerticalContentAlignment="Center" >
                            <Path Stretch="Uniform" Width="24" Height="24" Fill="#FF000000" Data="{StaticResource alphabeticalDescPathData}"/>                            
                        </Button>
                        <Button VerticalContentAlignment="Center" Margin="{StaticResource DefaultLeftMargin}">
                            <Path Stretch="Uniform" Width="24" Height="24" Fill="#FF000000" Data="{StaticResource arrowLeftRightPathData}"/>                            
                        </Button>
                        <Button VerticalContentAlignment="Center" Margin="{StaticResource DefaultLeftMargin}">
                            <Path Stretch="Uniform" Width="24" Height="24" Fill="#FF000000" Data="{StaticResource numericDescPathData}"/>
                        </Button>
                        -->
                        <!--</StackPanel>
                    </Border>-->

                    <content:ContentRightFileList Grid.Column="0" Grid.Row="3" Margin="{StaticResource SplitRight}" />
                    <GridSplitter Grid.Column="1" Grid.Row="3" />
                    <content:ContentLeftDbResult Grid.Column="2" Grid.Row="3" Margin="{StaticResource SplitLeft}" />                    

                </Grid>


                <!-- optional header -->
                <!--<Grid Margin="{StaticResource HeaderMargin}" HorizontalAlignment="Right" VerticalAlignment="Top">
                <Rectangle />
                <TextBlock Text="header" />
            </Grid>-->


                <!-- optional status -->
                <Grid Grid.Row="1" Margin="{StaticResource StatusMargin}" >
                    <StackPanel Orientation="Horizontal">
                        <TextBlock HorizontalAlignment="Left" Margin="{StaticResource DefaultLeftMargin}" Text="{Binding Status}" />
                        <Canvas HorizontalAlignment="Left" x:Name="canvas_alert" Margin="{StaticResource DefaultLeftMargin}" Width="20" Height="20" VerticalAlignment="Bottom" Visibility="Hidden">
                            <Path Fill="#FF000000" Stretch="Uniform" Width="16" Height="16" Data="{StaticResource alertPathData}" />
                        </Canvas>
                    </StackPanel>
                </Grid>
            </Grid>
        </Grid>
    </DockPanel>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="OnMediaPlayEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MainVM}">
            <ei:ChangePropertyAction TargetName="path_mediastatus" PropertyName="Data" Value="{StaticResource stopPathData}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="OnMediaStopEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MainVM}">
            <ei:ChangePropertyAction TargetName="path_mediastatus" PropertyName="Data" Value="{StaticResource playPathData}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="OnTagErrorEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=TrackTagVM}">
            <ei:ControlStoryboardAction Storyboard="{StaticResource stb_error}" />
        </i:EventTrigger>
        <!--<ei:DataTrigger Binding="{Binding IsProcessing}" Value="True">
            <i:InvokeCommandAction CommandParameter="{Binding }" Command="{x:Static view:ViewCommands.OpenProcessingDialogCommand}" />
        </ei:DataTrigger>-->
    </i:Interaction.Triggers>
</UserControl>
